package com.cj.peiwan.server.other;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

public class Alidayu {
    private static TaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "23383742", "bbef2d30c64e661f1c03eebf60592e86");

    public static void main(String[] args) throws ApiException {
//        sendOrderMessage("aaaaaaa","18874143580");
        System.out.println(sendOrderMessage("1234", "18874143580"));
    }


    public static boolean sendOrderMessage(String userNickname, String phone) throws ApiException {
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        req.setExtend("extend");
        req.setSmsType("normal");
        req.setSmsFreeSignName("邀请提醒");
        req.setSmsParamString("{\"user\":\"" + userNickname + "\"}");
        req.setRecNum(phone);
        req.setSmsTemplateCode("SMS_10401092");
        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
        return rsp.getResult().getSuccess();
    }

    public static boolean sendResetPwdMessage(String code, String phone) throws ApiException {
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        req.setExtend("extend");
        req.setSmsType("normal");
        req.setSmsFreeSignName("变更验证");
        req.setSmsParamString("{\"code\":\"" + code + "\",\"product\":\"美玩\"}");
        req.setRecNum(phone);
        req.setSmsTemplateCode("SMS_10365528");
        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
        return rsp.getResult().getSuccess();
    }

    public static boolean sendRegistMessage(String code, String phone) throws ApiException {
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        req.setExtend("extend");
        req.setSmsType("normal");
        req.setSmsFreeSignName("登录验证");
        req.setSmsParamString("{\"code\":\"" + code + "\",\"product\":\"美玩\"}");
        req.setRecNum(phone);
        req.setSmsTemplateCode("SMS_10365530");
        AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
        return rsp.getResult().getSuccess();
    }
}
